package cn.sytton.taffecloud.serivce.auth.controller;

import cn.sytton.taffecloud.common.base.doc.Api;
import cn.sytton.taffecloud.common.base.doc.ApiImplicitParam;
import cn.sytton.taffecloud.common.base.doc.ApiOperation;
import cn.sytton.taffecloud.common.base.doc.ParamType;
import cn.sytton.taffecloud.serivce.auth.model.LoginModel;
import cn.sytton.taffecloud.serivce.auth.service.ILoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 登录控制层
 *
 * @author skyrock
 */
@Api(tags = "登录")
@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    private ILoginService loginService;

    @ApiOperation("用户密码登录")
    @ApiImplicitParam(name = "loginModel", value = "登录对象", paramType = ParamType.body, dataTypeClass = LoginModel.class)
    @PostMapping("/pwd")
    public String loginPwd(@RequestBody LoginModel loginModel) {
        return loginService.loginByPwd(loginModel);
    }

    @ApiOperation("短信验证码登录")
    @ApiImplicitParam(name = "loginModel", value = "登录对象", paramType = ParamType.body, dataTypeClass = LoginModel.class)
    @PostMapping("/sms")
    public String loginSms(@RequestBody LoginModel loginModel) {
        return loginService.loginBySms(loginModel);
    }
}
